import ROUTES from './routes'
import core from './core'
import { pageReturn } from '@/utils'

export default class android extends core {
    constructor() {
        super()
    }
    defineFunc() {
        super.defineFunc()
        Object.keys(ROUTES).forEach(key => {
            window.TongBridge.paths[key] = ROUTES[key].android
        })

        window.addEventListener('pageback', (e) => {
            if (!window.noBackHandle) {
                if(import.meta.env.VITE_ENV === "prod"&&window.location.pathname==='/homeAI'){
                    window.TongBridge.closeWebview()
                    return 
                }
            }
        })

        let { safeBottom, safeTop, user, appVersion, bridgeVersion } = JSON.parse(TongBridge.getClientInfo())
        safeTop = safeTop / window.devicePixelRatio
        safeBottom = safeBottom / window.devicePixelRatio
        window.TongBridge.clientInfo = {
            user,
            safeBottom: safeBottom,
            safeTop: safeTop,
            appVersion,
            bridgeVersion: bridgeVersion || 0,
        }
    }
}